﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Niknak.Social.Twitter
{
    /// <summary>
    /// Default implementation of IMedia for basic presentation of Twitter media entities 
    /// </summary>
    public class Media : IMedia
    {
        /// <summary>
        /// Always the string version of the Int64 value
        /// </summary>
        public string MediaId { get; set; }

        /// <summary>
        /// Semi-expanded URL useful for giving a better idea of the destination address
        /// </summary>
        public string DisplayUrl { get; set; }

        /// <summary>
        /// Full URL
        /// </summary>
        public string ExpandedUrl { get; set; }

        /// <summary>
        /// Currently only picture
        /// </summary>
        public string MediaType { get; set; }

        /// <summary>
        /// Direct URL to the media rather than the page on which it is presented
        /// </summary>
        public string MediaUrl { get; set; }

        /// <summary>
        /// Secure version of MediaUrl
        /// </summary>
        public string MediaUrlHttps { get; set; }

        private MediaSize[] _Sizes { get; set; }
        /// <summary>
        /// Array of sizes that the media is available at
        /// </summary>
        public IMediaSize[] Sizes
        {
            get { return _Sizes; }
            set 
            {
                _Sizes = null;
                if (value != null && value.Any())
                    _Sizes = value.Cast<MediaSize>().ToArray();
            }
        }

        /// <summary>
        /// Shortened URL as originally found in the message
        /// </summary>
        public string Url { get; set; }

        /// <summary>
        /// Currently the same as the message creation date
        /// </summary>
        public DateTime CreatedAt { get; set; }

        public int[] Indices { get; set; }
    }
}
